﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO;
using System.Text;
using System.Windows.Threading;
using System.Windows.Browser;

namespace ReadGifBySL3
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        WebClient wcashx;

        void wcashx_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                ucGif.SetSoruce(e.Result as Stream);
            }
        }

        private void btnread_Click(object sender, RoutedEventArgs e)
        {
            //ucGif.UriSource = new Uri(tbxgifurl.Text,UriKind.Relative);
            wcashx = new WebClient();
            Uri endpoint = new Uri(string.Format("/ClientAccess.ashx?url={0}", tbxgifurl.Text), UriKind.Relative);
            wcashx.OpenReadCompleted += new OpenReadCompletedEventHandler(wcashx_OpenReadCompleted);
            wcashx.OpenReadAsync(endpoint);
        }
    }
}
